<?php


function shopperpress_homepage_hotselling($items){

	global $wpdb;

	if(get_option("display_homepage_num") ==""){ $DisplayNum=10; }else{ $DisplayNum=get_option("display_homepage_num"); }

	if($items !=""){ 
		$hotitems = explode(",",$items); $content="";
		$countRemains = $DisplayNum - count($hotitems);
	}else{
		$countRemains = $DisplayNum+1;
	}
	
 
	if($countRemains > 0){
		
		$data = shopperPress_featured($countRemains);
	 
		$i=1; while($i < $countRemains){ 
		
		$content .= '<div class="Row460" style="border-bottom:1px solid #eee; margin-bottom:10px;">
			<div class="Rowc">
				<div style="height:100px; ">
				<a href="'.$data[$i]['link'].'">
					<img src="'.SPImage($data[$i]['image']).'" alt="'.$data[$i]['title'].'" style="max-width:100px;" />
				</a>
				</div>
			</div>
			<div class="Rowb">
				<b><a href="'.$data[$i]['link'].'">
					'.substr($data[$i]['title'],0,55).'
				</a></b><br />			
			'. substr(strip_tags(strtolower($data[$i]['description'])),0,130).'
			</div>
			
			
		<div style="clear:both;"></div>
		</div>';

				
		 $i++; 		
		
		}
	
	}
	
	
	if(is_array($hotitems) && !empty($hotitems)){ 
 
	foreach($hotitems as $hot){ if(is_numeric($hot)){  
	 
		$featured = get_post( $hot );
	  
		$FeaturedImage = get_post_meta($featured->ID, "thumbnail", true);
	
		if($FeaturedImage==""){
		
			$FeaturedImage = get_post_meta($featured->ID, "image", true);
			
		}	 
		 
		$content .= '<div class="Row460" style="border-bottom:1px solid #eee; margin-bottom:10px;">
			<div class="Rowc">
				<a href="'.get_permalink($featured->ID).'">
					<img src="'.SPImage($FeaturedImage).'" alt="'.$featured->post_title.'" style="max-width:100px;" />
				</a>
			</div>
			<div class="Rowb">
				<b><a href="'.get_permalink($featured->ID).'">
					'.substr($featured->post_title,0,55).'
				</a></b><br />			
			'. substr(strip_tags(strtolower($featured->post_content)),0,130).'
			</div>
			
			
		
		</div>';
		
		$i++;
		
		 } 
		 
		 }
		 
	} 
		 
	return $content;

}

 